package cn.mothin.action;

import org.springframework.beans.factory.annotation.Autowired;

import cn.mothin.frame.bean.ActionResult;
import cn.mothin.frame.core.annotation.NeedLogon;
import cn.mothin.frame.core.base.BaseAction;
import cn.mothin.service.MainService;
import cn.mothin.vo.MainForm;

@SuppressWarnings("serial")
public class MainAction extends BaseAction {
    private MainForm mainForm = new MainForm();
    @Autowired
    private MainService mainService;

    @Override
    public Object getModel() {
        return mainForm;
    }

    @NeedLogon
    public String execute() {
        return SUCCESS;
    }

    /**
     * 当前登录用户的菜单数据
     * 
     * @return
     */
    @NeedLogon
    public String queryMenu() {
        ActionResult actionResult=ActionResult.getInstance();
        actionResult.setValue(mainService.queryLoginUserPermission());
        return renderJson(actionResult.toJson());
    }

    /**
     * 退出，清理session
     * 
     * @return
     */
    public String logout() {
        clearSession();
        return redirectTo("login");
    }
}
